package org.yray.sip.handler;


import lombok.extern.slf4j.Slf4j;
import org.yray.sip.base.MsgType;
import org.yray.sip.base.SipMsg;
import org.yray.sip.creator.MessageCreator;
import org.yray.sip.server.SipServerContext;
import org.yray.sip.server.SipSession;


@Slf4j
public class CancelHandler extends MessageHandler {

    /***
     * CANCEL sip:77001@172.130.13.31:14450;ob SIP/2.0
     Via: SIP/2.0/UDP 172.168.200.78;rport;branch=z9hG4bK3rvmF41a4jHjm
     Max-Forwards: 69
     From: "Extension 77001" <sip:77001@172.168.200.78>;tag=9QvmX5X1ZDpyQ
     To: <sip:77001@172.130.13.31:14450;ob>
     Call-ID: 5d079db0-d0de-123a-3f94-0050568cd49a
     CSeq: 44824917 CANCEL
     Reason: Q.850;cause=19;text="NO_ANSWER"
     Content-Length: 0
     * @param sipMsg
     * @return
     */
    @Override
    public String[] handler(SipMsg sipMsg, SipServerContext ssc) {
        SipSession sipSession=new SipSession(sipMsg,ssc.getRunIp(),ssc.getRunPort(),false);
        String result= MessageCreator.getCreator(MsgType.OK).createMsg(sipSession);
        return new String[]{result};
    }




}
